package br.affero.core.security;

import javax.inject.Inject;

import org.jboss.seam.security.Authenticator;
import org.jboss.seam.security.BaseAuthenticator;
import org.jboss.seam.security.Credentials;
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.management.PasswordHash;

public class SimpleAuthenticator extends BaseAuthenticator implements Authenticator {
    @Inject
    Identity identity;
    @Inject
    Credentials credentials;
    
    @Inject
    PasswordHash passwordHash;

    @Override
    public void authenticate() {
    	
       /* if ("demo".equals(credentials.getUsername())) {
            identity.addRole("admin", "USERS", "GROUP");
        }

        if ("user".equals(credentials.getUsername())) {
            identity.addGroup("USERS", "GROUP");
        }*/
    	
    	
    	//validate user and password
 
    	identity.addGroup("USERS", "GROUP");
    	identity.addGroup("ADMINS", "GROUP");
    	identity.addGroup("REVISOR","GROUP");
        identity.addRole("admin","USERS","GROUP");
        identity.addRole("user","USERS","GROUP");
        identity.addRole("teste","USERS","GROUP");
        
        
        // Let any user log in
        setStatus(AuthenticationStatus.SUCCESS);
        setUser(new ComplexUser(credentials.getUsername(),"Paulo Jorge Zagalo das Neves"));
    }
}
